using Core.SimpleTemp.Common;
using Core.SimpleTemp.Common.PagingQuery;
using Core.SimpleTemp.Entitys;
using Core.SimpleTemp.Repositories;
using Core.Toolkit.Common;
using Core.Toolkit.Core;
using Core.Toolkit.Core.Api;
using Core.Toolkit.Core.Application;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Core.SimpleTemp.Application
{
    [AutoDi()]
    public class CBS_CourseService : BaseAppService<CBS_CourseDto, CBS_Course, CBS_CourseRepository>
    {
        readonly ExcelHelp _excelHelp;
        public CBS_CourseService(CBS_CourseRepository repository, ExcelHelp excelHelp) : base(repository)
        {
            _excelHelp = excelHelp;
        }



        private LoadPageOffsetModelAuto<CBS_Course, CBS_CourseDto>
            GetLoadPageOffsetMode(PagingModel<CBS_CourseDto>
                pagingQueryModel)
        {
            var loadPageOffsetModel = this.GetLoadPageOffsetModelAuto(pagingQueryModel);
            var baseQuery = _repository.QueryBase().AsNoTracking();
            loadPageOffsetModel.QueryWhere = this.CreateQRList()

     .Add("CourseClassId", "=")
     .Add("TrainingCoursewareName", "=")
     .Add("TrainingCoursewareContent", "=")
     .Add("Annex", "=")
     .Add("CreateFactory", "=")
     .Add("CreateDept", "=")
     .Add("UpdateDept", "=");


            loadPageOffsetModel.BasqQuery = baseQuery;
            loadPageOffsetModel.Order = orderModel => orderModel.CreateTime;
            loadPageOffsetModel.Selector = model => new CBS_Course()
            {
                Id = model.Id,
                CourseClassId = model.CourseClassId,
                TrainingCoursewareName = model.TrainingCoursewareName,
                TrainingCoursewareContent = model.TrainingCoursewareContent,
                //Annex = model.Annex,
                AttachmentId = model.AttachmentId,
                CreateFactory = model.CreateFactory,
                CreateDept = model.CreateDept,
                UpdateDept = model.UpdateDept,
            };
            return loadPageOffsetModel;
        }


        public async Task<IPageModel<CBS_CourseDto>> GetList(PagingModel<CBS_CourseDto>
            pagingQueryModel)
        {
            var loadPageOffsetModel = GetLoadPageOffsetMode(pagingQueryModel);
            return await base.LoadPageOffsetAsync(loadPageOffsetModel);
        }


      



    }

}
